﻿namespace SRM.DataObjects
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    /// <summary>
    /// Summary description for SRM_Form
    /// </summary>
    [DataObjectAttribute(true)]
    public class SRM_Form
    {
        public SRM_Form()
        {
        }

        //[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        //public static DataTable GetApplicant(int applicant_key)
        //{
        //    DataTable dtResult = null;

        //    using (SqlConnection conn = new SqlConnection(Help.GetConnectionString("SRM")))
        //    {
        //        DataSet ds = new DataSet();
        //        SqlCommand cmd = conn.CreateCommand();
        //        SqlDataAdapter da = new SqlDataAdapter(cmd);


        //        cmd.CommandText = "SELECT ResumeFileName FROM SRM_Applicant_TBL WHERE ApplicantKey = @applicant_key;";
        //        cmd.Parameters.AddWithValue("@applicant_key", applicant_key);
        //        da.Fill(ds);

        //        dtResult = ds.Tables[0];
        //    }

        //    return dtResult;
        //}

        
        public static string GetApplicationFormXml(string applicantKey, string requisitionApplicantKey)
        {
            using (SqlConnection conn = new SqlConnection(Help.GetConnectionString("SRM")))
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = conn.CreateCommand();
                SqlDataAdapter da = new SqlDataAdapter(cmd);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetApplicationForm";
                cmd.Parameters.AddWithValue("@ApplicantKey", applicantKey);
                cmd.Parameters.AddWithValue("@RequisitionKey", requisitionApplicantKey);
                da.Fill(ds);

                return ds.GetXml();
            }
        }

        public static string GetEnrolmentFormXml(string applicantKey, string requisitionApplicantKey)
        {
            using (SqlConnection conn = new SqlConnection(Help.GetConnectionString("SRM")))
            {
                DataSet ds = new DataSet();
                SqlCommand cmd = conn.CreateCommand();
                SqlDataAdapter da = new SqlDataAdapter(cmd);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetEnrolmentForm";
                cmd.Parameters.AddWithValue("@ApplicantKey", applicantKey);
                cmd.Parameters.AddWithValue("@RequisitionKey", requisitionApplicantKey);
                da.Fill(ds);

                return ds.GetXml();
            }
        }
    }
}